package com.chenqi.controller;

import com.chenqi.model.entity.Tip;
import com.chenqi.service.TipService;
import com.chenqi.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: tip控制器
 * @program: ardaicommunity
 * @author: ChenQi
 * @create: 2021-03-2021/3/7-15-04
 */
@RestController
@RequestMapping("/api/v1/tip")
public class TipController {

    @Autowired
    private TipService tipService;

    /**
     * 随机获取名言
     * @return
     */
    @GetMapping("/today")
    public JsonData today() {
        Tip todayTip = tipService.getTodayTip();
        return todayTip == null ? JsonData.BuildError("获取失败") : JsonData.BuildSuccess(todayTip, "获取成功!");
    }
}
